package tests;
import static org.junit.Assert.*;
import java.sql.SQLException;
import java.util.Properties;

import model.AppModel;
import model.User;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import dao.DaoException;
/**
 * This class tests the AppModel class
 * 
 * @author buthainahaldosary
 * @since May 2013
 *
 * @version $Revision: 1.0 $
 */

public class TestAppModel {
	AppModel app;
	
	/**
	 * This method is called before every test case to setup a new AppModel.
	 */
	@Before
	public void setUp(){
		app=new AppModel(new Properties());
	}
	
	/**
	 * This method is called after every test case to tear down the AppModel and force 
	 * garbage collection.
	 */
	@After
	public void tearDown()
	{
		app=null;
		System.gc();
	}

	/**
	 * This test case tests the InitDao method and ensures the app was successfully initialized.
	
	
	
	 * @throws SQLException * @throws DaoException */
	@Test
	public void testInitDao() throws SQLException, DaoException {
		
		app.initDao();
		assertEquals("class model.AppModel",app.getClass().toString());
	}

/**
 * This test case tests the getUser method by ensuring that the user's name is equal to the one specified.
 */
	@Test
	public void testGetUser() {
		User user=new User("new user");
		app.setUser(user);
		User result=app.getUser();
		assertEquals("new user",result.getName());
		
		
		
	}

}
